package com.weeho.dongyong.service;

import com.weeho.dongyong.dao.TaskDetailDao;
import com.weeho.dongyong.entity.TaskDetail;
import com.weeho.dongyong.utils.StringHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskDetailService {
    @Autowired
    private TaskDetailDao taskDetailDao;

    public int insertSelective(TaskDetail record) {
        return taskDetailDao.insertSelective(record);
    }

    public int updateByPrimaryKeySelective(TaskDetail record) {
        return taskDetailDao.updateByPrimaryKeySelective(record);
    }

    public int deleteByPrimaryKey(String id) {
        return taskDetailDao.deleteByPrimaryKey(id);
    }

    public TaskDetail selectByPrimaryKey(String id) {
        return taskDetailDao.selectByPrimaryKey(id);
    }

    public List<TaskDetail> selectByCondition(TaskDetail record) {
        return taskDetailDao.selectByCondition(record);
    }

    public int addTaskDetail(TaskDetail taskDetail){
        taskDetail.setId(StringHelper.generatePrimaryKey());
        return insertSelective(taskDetail);
    }

    public List<TaskDetail> getTaskDetailByTaskId(String taskId){
        TaskDetail ta = new TaskDetail();
        ta.setFkTaskId(taskId);
        return selectByCondition(ta);
    }

}